<template>
    <div class="echart-chart">
        <div class="inside">
            <header><i class="el-icon-location-outline"></i> 租金涨幅百分比预测</header>
            <div class="chartBox clearfix" style="min-height: 100px;">
                <aside v-show="!chartNoDataShow">
                    <p>一年后租金预期：{{ isNull0_USD(zri_forecast) }}</p>
                    <p>一年后租金预期变化：{{ isNull0(forecast_yoy_change) }} </p>
                    <p>目前的租金同比变化：{{ isNull0(current_yoy_change) }} </p>
                </aside>
                <h4 ref="ZriForecast_Public_NoData" v-show="chartNoDataShow"></h4>
            </div>
            <p v-show="false">{{getzipcode}}</p>

        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                chartNoDataShow: false, //判断是否有无数据
                zri_forecast: '', //一年后租金预期
                forecast_yoy_change: '', //一年后租金预期变化
                current_yoy_change: '', //目前的租金同比变化

            }
        },
        computed: {
            //房源详情页图表使用——本房源所在邮zipcode
            getzipcode() {
                if(this.$store.getters.get_houseDetailsZipcode){
                    //获取租金涨幅百分比预测数据
                    this.get_ZriForecast_Public();
                }
                return this.$store.getters.get_houseDetailsZipcode
            }
        },
        created() {
        },
        mounted() {
        },
        methods: {
            //获取租金涨幅百分比预测数据
            get_ZriForecast_Public() {
                this.$get('/analysis/zri_forecast_public/89/'+ this.$store.getters.get_houseDetailsZipcode).then(res => {
                    if (res.status == 0) {
                        if(res.data != null){
                            this.chartNoDataShow = false;
                            this.zri_forecast = res.data.zri_forecast;
                            this.forecast_yoy_change = res.data.forecast_yoy_change ? (res.data.forecast_yoy_change * 100).toFixed(2) +'%' : 0;
                            this.current_yoy_change = res.data.current_yoy_change ? (res.data.current_yoy_change * 100).toFixed(2) +'%' : 0;
                        }else{
                            this.chartNoDataShow = true;
                            this.$refs.ZriForecast_Public_NoData.innerText = '暂未查询到数据！';
                        }
                    } else {
                        this.chartNoDataShow = true;
                        this.$refs.ZriForecast_Public_NoData.innerText = '暂未查询到数据！';
                    }
                });
            },
        },
        components: {}
    }
</script>

<style scoped lang="less" type="text/less">
</style>
